package phantri.uit.menunhahang;

import org.kobjects.base64.Base64;
import org.ksoap2.serialization.SoapObject;

import android.os.Parcelable;

import phantri.uit.menunhahang.MenuCalculate;

;

public class MonanObj extends AbstractModel {

	private static final String MONAN_ID = "ID_MA";
	private static final String MONAN_NAME = "Ten_MA";
	private static final String MONAN_DESCRIPTION = "Mota_MA";
	private static final String MONAN_PRICE = "Gia_MA";
	private static final String MONAN_INFO = "GioiThieu_MA";
	private static final String MONAN_ICON = "Hinh_MA";

	private String MonAn_Ten;
	private String MonAn_Mota;
	private String MonAn_Gia;
	private String MonAn_Gioithieu;
	private byte[] MonAn_Hinh;
	private int MonAn_Soluong=0;

	public void setName(String ten) {
		MonAn_Ten = ten;
	}

	public String getName() {
		return MonAn_Ten;
	}

	public void setDescription(String mota) {
		MonAn_Mota = mota;
	}

	public String getDescription() {
		return MonAn_Mota;
	}

	public void setPrice(String gia) {
		MonAn_Gia = gia;
	}

	public String getPrice() {
		return MonAn_Gia;
	}

	public void setInfo(String gioithieu) {
		MonAn_Gioithieu = gioithieu;
	}

	public String getInfo() {
		return MonAn_Gioithieu;
	}

	public void setIcon(byte[] icon) {
		MonAn_Hinh = icon;
	}

	public byte[] getIcon() {
		return MonAn_Hinh;
	}

	public int getSoluong() {
		return MonAn_Soluong;
	}

	public void setSoluong(int soluong) {
		this.MonAn_Soluong = soluong;
	}

	public void parse(Object obj) throws ClassCastException, RuntimeException {
		if (obj == null) {
			return;
		}

		SoapObject sobj = (SoapObject) obj;
		this.id = MenuCalculate
				.anyTypeToEmptyString(sobj.getProperty(MONAN_ID));
		this.MonAn_Ten = MenuCalculate.anyTypeToEmptyString(sobj
				.getProperty(MONAN_NAME));
		this.MonAn_Mota = MenuCalculate.anyTypeToEmptyString(sobj
				.getProperty(MONAN_DESCRIPTION));
		this.MonAn_Gia = MenuCalculate.anyTypeToEmptyString(sobj
				.getProperty(MONAN_PRICE));
		this.MonAn_Gioithieu = MenuCalculate.anyTypeToEmptyString(sobj
				.getProperty(MONAN_INFO));
		try {
			String temp = sobj.getProperty(MONAN_ICON).toString();
			if (temp != "") {
				this.MonAn_Hinh = Base64.decode(temp);
			}

		} catch (Exception e) {
			e.printStackTrace();
			this.MonAn_Hinh = null;
		}
	}
}
